package com.jeff.tianti.cms.dao;

import com.jeff.tianti.common.dao.CustomBaseSqlDaoImpl;
import com.jeff.tianti.common.entity.PageModel;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jeff.tianti.cms.entity.Resume;
import com.jeff.tianti.cms.dto.ResumeQueryDTO;
import org.apache.commons.lang3.StringUtils;

/**
 * @author liuyi
 * @desc ResumeDaoImpl类 
 * @date 2019-06-28
 */

public class ResumeDaoImpl extends CustomBaseSqlDaoImpl implements ResumeDaoCustom  {

    public PageModel<Resume> queryResumePage(ResumeQueryDTO resumeQueryDTO){
         Map<String,Object> map = new HashMap<String,Object>();
         StringBuilder hql = new StringBuilder();
        hql.append(" select t from Resume t where 1=1 ");
        if (resumeQueryDTO != null) {
            String jobName = resumeQueryDTO.getJobName();
            if (StringUtils.isNotBlank(jobName)) {
                hql.append(" and t.jobType = :jobType ");
                map.put("jobType", jobName);
            }
            String sortNum = resumeQueryDTO.getSortNum();
            if (StringUtils.isNoneBlank(sortNum) && !"-1".equals(sortNum)) {
                if ("desc".equals(sortNum)) {
                    hql.append(" order by t.createDate desc ");
                } else if ("asc".equals(sortNum)) {
                    hql.append(" order by t.createDate asc ");
                }
            }
        }
         return this.queryForPageWithParams(hql.toString(),map,resumeQueryDTO.getCurrentPage(),resumeQueryDTO.getPageSize());
    }

    public List<Resume> queryResumeList(ResumeQueryDTO resumeQueryDTO){
         Map<String,Object> map = new HashMap<String,Object>();
         StringBuilder hql = new StringBuilder();
         hql.append("select t from Resume t ");
         return this.queryByMapParams(hql.toString(),map);
    }


}